feat: Add WASM compatibility fallback from serpyco-rs to serpyco#671
Closed
devin-ai-integration[bot] wants to merge 6 commits intomainfrom
Closed
feat: Add WASM compatibility fallback from serpyco-rs to serpyco#671devin-ai-integration[bot] wants to merge 6 commits intomainfrom
devin-ai-integration[bot] wants to merge 6 commits intomainfrom
Conversation
- Add conditional dependencies in pyproject.toml using environment markers - Use sys_platform != 'emscripten' for serpyco-rs, sys_platform == 'emscripten' for serpyco - Update imports in airbyte_protocol_serializers.py, airbyte_protocol.py, entrypoint_wrapper.py, and test_source.py - Add conditional import logic to detect WASM/Pyodide environments at runtime - Maintain API compatibility between serpyco-rs and serpyco libraries - All tests pass with conditional imports Co-Authored-By: AJ Steers <aj@airbyte.io>
Contributor
Author
|
Original prompt from AJ Steers: |
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
👋 Greetings, Airbyte Team Member!Here are some helpful tips and reminders for your convenience. Testing This CDK VersionYou can test this version of the CDK using the following: # Run the CLI from this branch:
uvx 'git+https://github.com/airbytehq/airbyte-python-cdk.git@devin/1753304881-serpyco-wasm-fallback#egg=airbyte-python-cdk[dev]' --help
# Update a connector to use the CDK from this branch ref:
cd airbyte-integrations/connectors/source-example
poe use-cdk-branch devin/1753304881-serpyco-wasm-fallbackHelpful ResourcesPR Slash CommandsAirbyte Maintainers can execute the following slash commands on your PR:
|
…compliance - Change single quotes to double quotes in sys.platform conditional imports - Resolves MyPy Check and Ruff Format Check CI failures - All local linting and formatting checks now pass Co-Authored-By: AJ Steers <aj@airbyte.io>
- Resolved merge conflict in airbyte_protocol_serializers.py - Accepted remote USE_RUST_BACKEND approach which is cleaner - Combined with local formatting fixes for double quotes Co-Authored-By: AJ Steers <aj@airbyte.io>
…ports - Use TYPE_CHECKING conditional imports to avoid MyPy duplicate name definitions - Maintains runtime conditional import behavior for WASM compatibility - Local MyPy check now passes successfully on all 415 source files Co-Authored-By: AJ Steers <aj@airbyte.io>
- Fix import block sorting in airbyte_protocol_serializers.py - Remove extra blank line for proper formatting - All local Ruff checks now pass Co-Authored-By: AJ Steers <aj@airbyte.io>
Contributor
Author
|
Closing due to inactivity for more than 7 days. Configure here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: Add WASM compatibility fallback from serpyco-rs to serpyco
Summary
This PR implements a safe fallback mechanism from
serpyco-rsto pure Pythonserpycowhen running in WASM/Pyodide environments. The key changes:pyproject.tomlto installserpyco-rsonly whensys_platform != 'emscripten'andserpycowhensys_platform == 'emscripten'sys.platform == 'emscripten'to detect WASM environmentsCustomType,Serializer,SchemaValidationError, andAliasThis enables the CDK to work in WASM builds where Rust compilation (required by serpyco-rs) is not available, falling back to the pure Python implementation.
Review & Testing Checklist for Human
poetry installorpip installworks correctly in a Pyodide environment and installsserpycoinstead ofserpyco-rssys.platform == 'emscripten'detection is reliableCustomType,Serializerwithomit_none,SchemaValidationError,Alias) have identical APIs betweenserpycoandserpyco-rsserpycofallbackRecommended test plan: Set up a Pyodide environment, install the CDK, and run basic serialization operations to ensure the fallback works end-to-end.
Diagram
%%{ init : { "theme" : "default" }}%% graph TD pyproject["pyproject.toml<br/>Conditional Dependencies"]:::major-edit protocol_ser["airbyte_cdk/models/<br/>airbyte_protocol_serializers.py<br/>CustomType, Serializer imports"]:::major-edit protocol["airbyte_cdk/models/<br/>airbyte_protocol.py<br/>Alias import"]:::major-edit entrypoint["airbyte_cdk/test/<br/>entrypoint_wrapper.py<br/>SchemaValidationError import"]:::major-edit test_source["unit_tests/sources/<br/>test_source.py<br/>SchemaValidationError import"]:::major-edit serpyco_rs["serpyco-rs<br/>(Rust-based)"]:::context serpyco["serpyco<br/>(Pure Python)"]:::context pyproject -->|"sys_platform != 'emscripten'"| serpyco_rs pyproject -->|"sys_platform == 'emscripten'"| serpyco protocol_ser -->|"Runtime detection"| serpyco_rs protocol_ser -->|"Runtime detection"| serpyco protocol -->|"Runtime detection"| serpyco_rs protocol -->|"Runtime detection"| serpyco entrypoint -->|"Runtime detection"| serpyco_rs entrypoint -->|"Runtime detection"| serpyco test_source -->|"Runtime detection"| serpyco_rs test_source -->|"Runtime detection"| serpyco subgraph Legend L1[Major Edit]:::major-edit L2[Minor Edit]:::minor-edit L3[Context/No Edit]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes
Link to Devin run: https://app.devin.ai/sessions/131f07de5c85420b977fd878c5e7d90e
Requested by: Aaron ("AJ") Steers (@aaronsteers)